/*
 *  ppi.h
 *  
 *	Defines shared data structures for PPI:
 *	- Channels
 *	- Services
 *  - Sensors
 *	
 *  Created by Philip Asare on 8/5/10.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef PPI_H
#define PPI_H

/* protocol costraints */
#define MAX_DEVICES		6
#define MAX_SERVICES	6
#define MAX_CHANNELS	12

/* data structures */

typedef struct {
	uint8_t sid;
	uint8_t dev_type;
	uint8_t channel_type;
} ppi_sensor;

typedef struct{
	uint8_t cid;
	ppi_sensor *service;
} ppi_channel;

/** PACKET **/
typedef struct{
	uint16_t src_addr;
	uint16_t dest_addr;
	uint8_t type;
	uint8_t info;
} ppi_pkt;

/* packet types */

#define DISCOVER		(0x01)
#define CONNECT			(0x01 << 1)
#define CHANNEL_SETUP	(0x01 << 2)
#define CHANNEL_BREAK	(0x01 << 3)
#define TRANSFER		(0x01 << 4)
#define DISCONNECT		(0x01 << 5)

#define BROADCAST		0xffff

/* device types */

#define SPO2			0x01
#define HR				0x02
#define	Bp				0x03
#define	SCALE			0x04
#define	ECG				0x05

/* tdma slot allocations */

#define PPI_DISCOVER_SLOT	2



#endif

